package com.liquidcode.cellular;

import collisionPrimitives.CRect;
import entities.CPlayer;

public class CCamera {
	
	private static CCamera mInstance; 
	private float m_fFollowSpeed; 
	private CRect m_viewport; 
	private int m_screenWidth; 
	private int m_screenHeight;
	
	private CCamera()
	{
		m_fFollowSpeed = 2.0f;
		m_viewport = new CRect();
	}
	
	public static CCamera getInstance()
	{
		if( mInstance == null )
			mInstance = new CCamera();
		
		return mInstance; 
	}
	
	public void Update(float dt)
	{
		m_viewport.min.setX(CPlayer.getInstance().getPosX() - m_screenWidth*0.5f);
		m_viewport.min.setY(CPlayer.getInstance().getPosY() - m_screenHeight*0.5f);
		m_viewport.max.setX(CPlayer.getInstance().getPosX() + m_screenWidth*0.5f);
		m_viewport.max.setY(CPlayer.getInstance().getPosY() + m_screenHeight*0.5f);
	}
	
	public void SetScreenSpace(int w, int h)
	{
		m_screenWidth = w; 
		m_screenHeight = h;
	}
	
	
	// Accessors
	public CRect getViewport() { return m_viewport; }
}
